package com.webware.one.server.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.webware.one.server.domain.Person;
import com.webware.one.server.domain.User;
import com.webware.one.server.domain.UserCredentials;
import com.webware.one.shared.type.EUserRole;

@Entity(name = "User")
@Table(name = "T_USER")
public class User extends AbstractEntity {

    @JoinColumn(nullable = true)
    @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, targetEntity = Person.class)
    private Person person = null;

    @JoinColumn(nullable = true)
    @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, targetEntity = UserCredentials.class)
    private UserCredentials credentials = null;

    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private EUserRole role = EUserRole.GUEST;

    public Person getPerson() {
	return person;
    }

    public void setPerson(Person person) {
	this.person = person;
    }

    public UserCredentials getCredentials() {
	return credentials;
    }

    public void setCredentials(UserCredentials credentials) {
	this.credentials = credentials;
    }

    public EUserRole getRole() {
	return role;
    }

    public void setRole(EUserRole role) {
	this.role = role;
    }
}
